<?php

namespace App\Http\Controllers\Main;

use App\Cases;
use App\CrmProductCategory;
use App\CrmProduct;
use App\Slide;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Article;
use App\CrmIndustry;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;

class IndexController extends Controller
{
    public function index()
    {
        $a = Input::get('a',0);
        #检测是否是移动产品
        if($this->is_mobile() && $a==0){
            return Redirect::to('mobile');
        }
        #获取首页显示新闻
        $news = Article::where('status', 1)->orderBy("rank", "desc")->orderBy("create_time", "desc")->skip(0)->take(3)->get();
        #获取轮播图信息
        $slide = Slide::orderBy('rank','desc')->get();
//dd($slide->toArray());
        $productCate = $this->productCate();
        #获取行业
        $industry = CrmIndustry::where('status',1)->get()->toArray();
//        dump($productCate);
        $color = 1;
        return view('main/index',compact('news','productCate','industry','color','slide'));
    }
}
